#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "Core/SendingMsgDealer.h"
#include "Buffer/InfoBuffer.h"
#include "CallBacker/EncryptCallBacker.cpp"

void testOneRTT()
{
	SendingMsgDealer sender("127.0.0.1");
	sender.sendMsg("negotiation_One");
	if(sender.receiveMsg()=="OK"){
		cout<<sender.oneRTTNegotiate("")<<endl;
	}
}

void testZeroRTT()
{
	SendingMsgDealer *sender=SendingMsgDealer::get_instance("127.0.0.1");
	sender->sendMsg("negotiation_Zero");
	sender->zeroRTTNegotiate("app_data");
	delete sender;
	InfoBuffer *buffer=InfoBuffer::get_instance();
	string key=buffer-> getEncryptKey();
	delete buffer;
}

void testEncryptNegotiation()
{
	SendingMsgDealer *sender=SendingMsgDealer::get_instance("127.0.0.1");
	sender->sendMsg("negotiation_Encrypt");
	if(sender->receiveMsg()=="OK"){
		map<string,string> param;
		param.insert(make_pair("method","AES"));
		param.insert(make_pair("model","ECB"));
		param.insert(make_pair("data","whole data"));
		sender->encryptNegotiate(param);
	}
	delete sender;
}
void test_encrypt()
{
	SendingMsgDealer sender("127.0.0.1");
	sender.sendMsg("encrypt");
	if(sender.receiveMsg()=="OK"){
		sender.encrypt();
	}
}
int main()
{
	//testZeroRTT();
	//testEncryptNegotiation();
	testOneRTT();
	test_encrypt();
	
	return 0;
}